-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[Entitlements] Add an option to perform bytecode verification during instrumentation #124404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Entitlements] Add an option to perform bytecode verification during instrumentation #124404
Conversation
|
I've tried to use the ClassFile API (82207ac) but that is too invasive: it forces classes to load, they get loaded into the wrong loader, and this causes troubles down the road. |
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple questions
...vider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java
Show resolved
Hide resolved
...vider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java
Outdated
Show resolved
Hide resolved
...vider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java
Outdated
Show resolved
Hide resolved
...main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumentationServiceImpl.java
Outdated
Show resolved
Hide resolved
...vider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java
Show resolved
Hide resolved
|
Let me add some more information on what I have found so far about failing verification in the "before" case (so for classes that should be as they are in the JDK). So far, from all the classes we transform, they both fail for a single cause (in a different way, but the error is the same): One thing I'm not sure is if this is a problem with the verification, with the verification done at that stage (during transformation), or with the classes themselves. The last one seems a bit unlikely, but possible: I think that if they are verified one by one, without "context", they would not be problematic, they would have valid structure and bytecode in isolation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better, a couple more nits
...vider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java
Outdated
Show resolved
Hide resolved
...nt/src/main/java/org/elasticsearch/entitlement/initialization/EntitlementInitialization.java
Show resolved
Hide resolved
…atte/elasticsearch into entitlements/instrumentation-verify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one final nit
...nt/src/main/java/org/elasticsearch/entitlement/initialization/EntitlementInitialization.java
Show resolved
Hide resolved
…instrumentation (elastic#124404) Using ASM CheckClassAdapter was key to diagnose the issue we had with incorrect signatures for some check methods. In this PR I polished up the code I used to pinpoint the issue, and made it available via a system property so it can be turned on if we need it (and it's always on for Entitlements IT tests too). It is also turned on in case we get VerifyErrors during retransformClasses early in the Entitlement agent bootstrap: retransformClasses runs in the native part of the JVM, so the VerifyError it produces is not so readable (e.g. it lacks a full stack trace and a description); in case this happens, we re-apply the transformation with verification turned on to get a meaningful error before dying.
💔 Backport failed
You can use sqren/backport to manually backport by running |
…instrumentation (elastic#124404) Using ASM CheckClassAdapter was key to diagnose the issue we had with incorrect signatures for some check methods. In this PR I polished up the code I used to pinpoint the issue, and made it available via a system property so it can be turned on if we need it (and it's always on for Entitlements IT tests too). It is also turned on in case we get VerifyErrors during retransformClasses early in the Entitlement agent bootstrap: retransformClasses runs in the native part of the JVM, so the VerifyError it produces is not so readable (e.g. it lacks a full stack trace and a description); in case this happens, we re-apply the transformation with verification turned on to get a meaningful error before dying.
…instrumentation (elastic#124404) Using ASM CheckClassAdapter was key to diagnose the issue we had with incorrect signatures for some check methods. In this PR I polished up the code I used to pinpoint the issue, and made it available via a system property so it can be turned on if we need it (and it's always on for Entitlements IT tests too). It is also turned on in case we get VerifyErrors during retransformClasses early in the Entitlement agent bootstrap: retransformClasses runs in the native part of the JVM, so the VerifyError it produces is not so readable (e.g. it lacks a full stack trace and a description); in case this happens, we re-apply the transformation with verification turned on to get a meaningful error before dying.
…instrumentation (#124404) (#125226) Using ASM CheckClassAdapter was key to diagnose the issue we had with incorrect signatures for some check methods. In this PR I polished up the code I used to pinpoint the issue, and made it available via a system property so it can be turned on if we need it (and it's always on for Entitlements IT tests too). It is also turned on in case we get VerifyErrors during retransformClasses early in the Entitlement agent bootstrap: retransformClasses runs in the native part of the JVM, so the VerifyError it produces is not so readable (e.g. it lacks a full stack trace and a description); in case this happens, we re-apply the transformation with verification turned on to get a meaningful error before dying.
…instrumentation (#124404) (#125224) Using ASM CheckClassAdapter was key to diagnose the issue we had with incorrect signatures for some check methods. In this PR I polished up the code I used to pinpoint the issue, and made it available via a system property so it can be turned on if we need it (and it's always on for Entitlements IT tests too). It is also turned on in case we get VerifyErrors during retransformClasses early in the Entitlement agent bootstrap: retransformClasses runs in the native part of the JVM, so the VerifyError it produces is not so readable (e.g. it lacks a full stack trace and a description); in case this happens, we re-apply the transformation with verification turned on to get a meaningful error before dying.
…instrumentation (#124404) (#125218) Using ASM CheckClassAdapter was key to diagnose the issue we had with incorrect signatures for some check methods. In this PR I polished up the code I used to pinpoint the issue, and made it available via a system property so it can be turned on if we need it (and it's always on for Entitlements IT tests too). It is also turned on in case we get VerifyErrors during retransformClasses early in the Entitlement agent bootstrap: retransformClasses runs in the native part of the JVM, so the VerifyError it produces is not so readable (e.g. it lacks a full stack trace and a description); in case this happens, we re-apply the transformation with verification turned on to get a meaningful error before dying.
…instrumentation (elastic#124404) Using ASM CheckClassAdapter was key to diagnose the issue we had with incorrect signatures for some check methods. In this PR I polished up the code I used to pinpoint the issue, and made it available via a system property so it can be turned on if we need it (and it's always on for Entitlements IT tests too). It is also turned on in case we get VerifyErrors during retransformClasses early in the Entitlement agent bootstrap: retransformClasses runs in the native part of the JVM, so the VerifyError it produces is not so readable (e.g. it lacks a full stack trace and a description); in case this happens, we re-apply the transformation with verification turned on to get a meaningful error before dying.
…instrumentation (elastic#124404) Using ASM CheckClassAdapter was key to diagnose the issue we had with incorrect signatures for some check methods. In this PR I polished up the code I used to pinpoint the issue, and made it available via a system property so it can be turned on if we need it (and it's always on for Entitlements IT tests too). It is also turned on in case we get VerifyErrors during retransformClasses early in the Entitlement agent bootstrap: retransformClasses runs in the native part of the JVM, so the VerifyError it produces is not so readable (e.g. it lacks a full stack trace and a description); in case this happens, we re-apply the transformation with verification turned on to get a meaningful error before dying.
Using ASM CheckClassAdapter was key to diagnose the issue we had with incorrect signatures for some check methods.
In this PR I polished up the code I used to pinpoint the issue, and made it available via a system property so it can be turned on if we need it (and it's always on for Entitlements IT tests too).
It is also turned on in case we get VerifyErrors during retransformClasses early in the Entitlement agent bootstrap:
retransformClassesruns in the native part of the JVM, so theVerifyErrorit produces is not so readable (e.g. it lacks a full stack trace and a description); in case this happens, we re-apply the transformation with verification turned on to get a meaningful error before dying.